fix: server network access and YouTube Shorts support - #233
Merged
Conversation
Normalize youtube.com/shorts/<videoId> to the standard watch?v= form so yt-dlp receives a URL its extractor already handles. Adds two test cases covering www. and m. variants.
Two layers were blocking headless server deployments from accepting network clients (reported in discussion #216): 1. docker-compose.yml bound to 127.0.0.1:8000 - Docker itself rejected connections from the network before they reached the app. 2. _default_allow_network() returned False unconditionally, so the network_gate middleware blocked all non-loopback requests even when Docker networking was configured correctly. Fix both: bind the Docker port to 0.0.0.0 and derive the network default from STEMDECK_DESKTOP - desktop keeps its secure off-by-default behavior; server/Docker deployments open the gate automatically since network access is the entire point of a headless deployment. STEMDECK_ALLOW_NETWORK still takes precedence when set explicitly.
Rename test_default_is_off to clarify it covers desktop mode (now requires STEMDECK_DESKTOP=1). Add test_default_is_on_in_server_mode covering the new behavior where allow_network defaults to True when STEMDECK_DESKTOP is absent.
Network toggle and port field are desktop-only controls. In server mode (no window.__TAURI__) the port is fixed by Docker and network access is on by default, so exposing these controls is misleading. Hide both from the Advanced settings tab when not running inside Tauri.
In server mode (no Tauri) the network toggle is always on and the port is fixed by Docker, so both controls are shown but disabled so the user can see the current state without being able to change them.
Show a explanatory note at the top of the Advanced tab when running in server mode so users know the network and port controls are intentionally locked and where to make changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
docker-compose.ymlwas binding to127.0.0.1(Docker host level) and_default_allow_network()was returningFalseunconditionally (application level). Nowallow_networkdefaults toTruewhenSTEMDECK_DESKTOPis not set, and the Docker port binding is0.0.0.0.STEMDECK_ALLOW_NETWORKstill overrides either way.normalize_youtube_url()now mapsyoutube.com/shorts/<videoId>to the standardwatch?v=form before handing the URL to yt-dlp.Test plan
docker compose -f build/docker-compose.yml up --build, access from another device on the LAN - should load without "not available on the network".STEMDECK_DESKTOP=1mode:get_allow_network()returnsFalse(desktop keeps network off by default).STEMDECK_ALLOW_NETWORK=0with noSTEMDECK_DESKTOP: explicit override still locks network off.https://www.youtube.com/shorts/<id>) - should process successfully.uv run pytest tests/test_url_validation.py -v- all 18 tests pass.